<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">

<title>strftime_formatting - RDoc Documentation</title>


<script src="./js/navigation.js" defer></script>
<script src="./js/search.js" defer></script>
<script src="./js/search_index.js" defer></script>
<script src="./js/searcher.js" defer></script>
<script src="./js/darkfish.js" defer></script>

<script src="./js/jquery-3.2.0.min.js"></script>

<script src="./js/vue.min.js"></script>
<script src="./js/js.cookie.min.js"></script>

<link href="./css/fonts.css" rel="stylesheet">
<link id='rdoccss' href="./css/rdoc.css" rel="stylesheet">
<link href="./css/carbon17.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
  var index_rel_prefix = "./";
  var darkModeCsseHref = "./css/rdoc-dm.css"
  var defaultModeCssHref = "./css/rdoc.css"
  // var cssDarkmode = Cookies.get('darkmode');
  
  if( Cookies.get("darkmode") == "true") {
	$('#rdoccss').attr("href", darkModeCsseHref);
}

//  https://cssdeck.com/blog/simple-jquery-stylesheet-switcher/

document.write('<style type="text/css">body{display:none}</style>');

</script>


</head>
<body id="top" role="document" class="file">
  <!-- this is page.html -->
  <div id='actionbar' >
    <div class='wrapper mdiv'>
      <ul class='grids g0'></ul>
    </div> 
    <!-- VERSION HEADER for 3.3.0-preview2 NOT FOUND -->
  </div> <!-- end action bar -->


 <div class='wrapper hdiv'>

 


<nav id='vapp' role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2><a href="./index.html" rel="home">Home</a></h2>

  <div id="table-of-contents-navigation"  >
    <a href="./table_of_contents.html#pages">Pages</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search" spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  
<div class="nav-section">
  <h3>Table of Contents</h3>

  <ul class="link-list" role="directory">
    <li><a href="#label-Formats+for+Dates+and+Times">Formats for Dates and Times</a>
    <li><a href="#label-Conversion+Specifiers">Conversion Specifiers</a>
    <li><a href="#label-Date+-28Year-2C+Month-2C+Day-29">Date (Year, Month, Day)</a>
    <li><a href="#label-Time+-28Hour-2C+Minute-2C+Second-2C+Subsecond-29">Time (Hour, Minute, Second, Subsecond)</a>
    <li><a href="#label-Timezone">Timezone</a>
    <li><a href="#label-Weekday">Weekday</a>
    <li><a href="#label-Week+Number">Week Number</a>
    <li><a href="#label-Week+Dates">Week Dates</a>
    <li><a href="#label-Literals">Literals</a>
    <li><a href="#label-Shorthand+Conversion+Specifiers">Shorthand Conversion Specifiers</a>
    <li><a href="#label-Flags">Flags</a>
    <li><a href="#label-Padding+Flags">Padding Flags</a>
    <li><a href="#label-Casing+Flags">Casing Flags</a>
    <li><a href="#label-Timezone+Flags">Timezone Flags</a>
    <li><a href="#label-Width+Specifiers">Width Specifiers</a>
    <li><a href="#label-Specialized+Format+Strings">Specialized Format Strings</a>
    <li><a href="#label-HTTP+Format">HTTP Format</a>
    <li><a href="#label-RFC+3339+Format">RFC 3339 Format</a>
    <li><a href="#label-RFC+2822+Format">RFC 2822 Format</a>
    <li><a href="#label-JIS+X+0301+Format">JIS X 0301 Format</a>
    <li><a href="#label-ISO+8601+Format+Specifications">ISO 8601 Format Specifications</a>
    <li><a href="#label-Dates">Dates</a>
    <li><a href="#label-Times">Times</a>
    <li><a href="#label-Combined+Date+and+Time">Combined Date and Time</a>
  </ul>
</div>

  <button id='toggleThing' @click="toggleNav()" >Show/hide navigation</button>

  <div id="project-metadata">
   <div :class="isOpen ? 'block' : 'hidden' " id='toggleMe'>
    
<div id="fileindex-section" class="nav-section">
  <h3>Pages</h3>

  <ul class="link-list">
    <li><a href="./NEWS/NEWS-1_8_7.html">NEWS-1.8.7</a>
    <li><a href="./NEWS/NEWS-1_9_1.html">NEWS-1.9.1</a>
    <li><a href="./NEWS/NEWS-1_9_2.html">NEWS-1.9.2</a>
    <li><a href="./NEWS/NEWS-1_9_3.html">NEWS-1.9.3</a>
    <li><a href="./NEWS/NEWS-2_0_0.html">NEWS-2.0.0</a>
    <li><a href="./NEWS/NEWS-2_1_0.html">NEWS-2.1.0</a>
    <li><a href="./NEWS/NEWS-2_2_0.html">NEWS-2.2.0</a>
    <li><a href="./NEWS/NEWS-2_3_0.html">NEWS-2.3.0</a>
    <li><a href="./NEWS/NEWS-2_4_0.html">NEWS-2.4.0</a>
    <li><a href="./NEWS/NEWS-2_5_0.html">NEWS-2.5.0</a>
    <li><a href="./NEWS/NEWS-2_6_0.html">NEWS-2.6.0</a>
    <li><a href="./NEWS/NEWS-2_7_0.html">NEWS-2.7.0</a>
    <li><a href="./NEWS/NEWS-3_0_0_md.html">NEWS-3.0.0</a>
    <li><a href="./NEWS/NEWS-3_1_0_md.html">NEWS-3.1.0</a>
    <li><a href="./NEWS/NEWS-3_2_0_md.html">NEWS-3.2.0</a>
    <li><a href="./bsearch_rdoc.html">bsearch</a>
    <li><a href="./bug_triaging_rdoc.html">bug_triaging</a>
    <li><a href="./case_mapping_rdoc.html">case_mapping</a>
    <li><a href="./character_selectors_rdoc.html">character_selectors</a>
    <li><a href="./command_injection_rdoc.html">command_injection</a>
    <li><a href="./contributing_md.html">contributing</a>
    <li><a href="./contributing/building_ruby_md.html">building_ruby</a>
    <li><a href="./contributing/documentation_guide_md.html">documentation_guide</a>
    <li><a href="./contributing/glossary_md.html">glossary</a>
    <li><a href="./contributing/making_changes_to_ruby_md.html">making_changes_to_ruby</a>
    <li><a href="./contributing/making_changes_to_stdlibs_md.html">making_changes_to_stdlibs</a>
    <li><a href="./contributing/reporting_issues_md.html">reporting_issues</a>
    <li><a href="./contributing/testing_ruby_md.html">testing_ruby</a>
    <li><a href="./dig_methods_rdoc.html">dig_methods</a>
    <li><a href="./distribution_md.html">distribution</a>
    <li><a href="./dtrace_probes_rdoc.html">dtrace_probes</a>
    <li><a href="./encodings_rdoc.html">encodings</a>
    <li><a href="./extension_ja_rdoc.html">extension.ja</a>
    <li><a href="./extension_rdoc.html">extension</a>
    <li><a href="./fiber_md.html">fiber</a>
    <li><a href="./format_specifications_rdoc.html">format_specifications</a>
    <li><a href="./globals_rdoc.html">globals</a>
    <li><a href="./implicit_conversion_rdoc.html">implicit_conversion</a>
    <li><a href="./keywords_rdoc.html">keywords</a>
    <li><a href="./maintainers_md.html">maintainers</a>
    <li><a href="./marshal_rdoc.html">marshal</a>
    <li><a href="./memory_view_md.html">memory_view</a>
    <li><a href="./optparse/argument_converters_rdoc.html">argument_converters</a>
    <li><a href="./optparse/creates_option_rdoc.html">creates_option</a>
    <li><a href="./optparse/option_params_rdoc.html">option_params</a>
    <li><a href="./optparse/tutorial_rdoc.html">tutorial</a>
    <li><a href="./packed_data_rdoc.html">packed_data</a>
    <li><a href="./ractor_md.html">ractor</a>
    <li><a href="./regexp_rdoc.html">regexp</a>
    <li><a href="./regexp/methods_rdoc.html">methods</a>
    <li><a href="./regexp/unicode_properties_rdoc.html">unicode_properties</a>
    <li><a href="./ruby_3_3_0_preview2/COPYING.html">COPYING</a>
    <li><a href="./ruby_3_3_0_preview2/COPYING_ja.html">COPYING.ja</a>
    <li><a href="./ruby_3_3_0_preview2/LEGAL.html">LEGAL</a>
    <li><a href="./ruby_3_3_0_preview2/NEWS_md.html">NEWS</a>
    <li><a href="./ruby_3_3_0_preview2/README_ja_md.html">README.ja</a>
    <li><a href="./ruby_3_3_0_preview2/README_md.html">README</a>
    <li><a href="./security_rdoc.html">security</a>
    <li><a href="./signals_rdoc.html">signals</a>
    <li><a href="./standard_library_rdoc.html">standard_library</a>
    <li><a href="./strftime_formatting_rdoc.html">strftime_formatting</a>
    <li><a href="./syntax_rdoc.html">syntax</a>
    <li><a href="./syntax/assignment_rdoc.html">assignment</a>
    <li><a href="./syntax/calling_methods_rdoc.html">calling_methods</a>
    <li><a href="./syntax/comments_rdoc.html">comments</a>
    <li><a href="./syntax/control_expressions_rdoc.html">control_expressions</a>
    <li><a href="./syntax/exceptions_rdoc.html">exceptions</a>
    <li><a href="./syntax/literals_rdoc.html">literals</a>
    <li><a href="./syntax/methods_rdoc.html">methods</a>
    <li><a href="./syntax/miscellaneous_rdoc.html">miscellaneous</a>
    <li><a href="./syntax/modules_and_classes_rdoc.html">modules_and_classes</a>
    <li><a href="./syntax/pattern_matching_rdoc.html">pattern_matching</a>
    <li><a href="./syntax/precedence_rdoc.html">precedence</a>
    <li><a href="./syntax/refinements_rdoc.html">refinements</a>
    <li><a href="./timezones_rdoc.html">timezones</a>
    <li><a href="./windows_md.html">windows</a>
    <li><a href="./yjit/yjit_md.html">yjit</a>
    <li><a href="./yjit/yjit_hacking_md.html">yjit_hacking</a>
  </ul>
</div>

   </div>
  </div>
</nav>


<!--  carbon ads here -->

<div id='extraz'>
  <div class='adzbox-index'  >
   
  </div>
 </div>         


<main role="main" aria-label="Page strftime_formatting.rdoc">

<h2 id="label-Formats+for+Dates+and+Times">Formats for Dates and Times<span><a href="#label-Formats+for+Dates+and+Times">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Several Ruby time-related classes have instance method <code>strftime</code>, which returns a formatted string representing all or part of a date or time:</p>
<ul><li>
<p>Date#strftime.</p>
</li><li>
<p>DateTime#strftime.</p>
</li><li>
<p><a href="Time.html#method-i-strftime"><code>Time#strftime</code></a>.</p>
</li></ul>

<p>Each of these methods takes optional argument <code>format</code>, which has zero or more embedded <em>format</em> <em>specifications</em> (see below).</p>

<p>Each of these methods returns the string resulting from replacing each format specification embedded in <code>format</code> with a string form of one or more parts of the date or time.</p>

<p>A simple example:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%H:%M:%S&#39;</span>) <span class="ruby-comment"># =&gt; &quot;14:02:07&quot;</span>
</pre>

<p>A format specification has the form:</p>

<pre>%[flags][width]conversion</pre>

<p>It consists of:</p>
<ul><li>
<p>A leading percent character.</p>
</li><li>
<p>Zero or more <em>flags</em> (each is a character).</p>
</li><li>
<p>An optional <em>width</em> <em>specifier</em> (an integer).</p>
</li><li>
<p>A <em>conversion</em> <em>specifier</em> (a character).</p>
</li></ul>

<p>Except for the leading percent character, the only required part is the conversion specifier, so we begin with that.</p>

<h3 id="label-Conversion+Specifiers">Conversion Specifiers<span><a href="#label-Conversion+Specifiers">&para;</a> <a href="#top">&uarr;</a></span></h3>

<h4 id="label-Date+-28Year-2C+Month-2C+Day-29">Date (Year, Month, Day)<span><a href="#label-Date+-28Year-2C+Month-2C+Day-29">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><code>%Y</code> - Year including century, zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y&#39;</span>)        <span class="ruby-comment"># =&gt; &quot;2022&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">-1000</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;-1000&quot; # Before common era.</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">10000</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;10000&quot; # Far future.</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">10</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y&#39;</span>)    <span class="ruby-comment"># =&gt; &quot;0010&quot;  # Zero-padded by default.</span>
</pre>
</li><li>
<p><code>%y</code> - Year without century, in range (0.99), zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%y&#39;</span>)    <span class="ruby-comment"># =&gt; &quot;22&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;01&quot; # Zero-padded by default.</span>
</pre>
</li><li>
<p><code>%C</code> - Century, zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%C&#39;</span>)        <span class="ruby-comment"># =&gt; &quot;20&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">-1000</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%C&#39;</span>) <span class="ruby-comment"># =&gt; &quot;-10&quot; # Before common era.</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">10000</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%C&#39;</span>) <span class="ruby-comment"># =&gt; &quot;100&quot; # Far future.</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">100</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%C&#39;</span>)   <span class="ruby-comment"># =&gt; &quot;01&quot;  # Zero-padded by default.</span>
</pre>
</li><li>
<p><code>%m</code> - Month of the year, in range (1..12), zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%m&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;01&quot; # Zero-padded by default.</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">12</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%m&#39;</span>) <span class="ruby-comment"># =&gt; &quot;12&quot;</span>
</pre>
</li><li>
<p><code>%B</code> - Full month name, capitalized:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%B&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;January&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">12</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%B&#39;</span>) <span class="ruby-comment"># =&gt; &quot;December&quot;</span>
</pre>
</li><li>
<p><code>%b</code> - Abbreviated month name, capitalized:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%b&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;Jan&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">12</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%h&#39;</span>) <span class="ruby-comment"># =&gt; &quot;Dec&quot;</span>
</pre>
</li><li>
<p><code>%h</code> - Same as <code>%b</code>.</p>
</li><li>
<p><code>%d</code> - Day of the month, in range (1..31), zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%d&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;01&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>, <span class="ruby-value">1</span>, <span class="ruby-value">31</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%d&#39;</span>) <span class="ruby-comment"># =&gt; &quot;31&quot;</span>
</pre>
</li><li>
<p><code>%e</code> - Day of the month, in range (1..31), blank-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%e&#39;</span>)  <span class="ruby-comment"># =&gt; &quot; 1&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>, <span class="ruby-value">1</span>, <span class="ruby-value">31</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%e&#39;</span>) <span class="ruby-comment"># =&gt; &quot;31&quot;</span>
</pre>
</li><li>
<p><code>%j</code> - Day of the year, in range (1..366), zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%j&#39;</span>)   <span class="ruby-comment"># =&gt; &quot;001&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>, <span class="ruby-value">12</span>, <span class="ruby-value">31</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%j&#39;</span>) <span class="ruby-comment"># =&gt; &quot;365&quot;</span>
</pre>
</li></ul>

<h4 id="label-Time+-28Hour-2C+Minute-2C+Second-2C+Subsecond-29">Time (Hour, Minute, Second, Subsecond)<span><a href="#label-Time+-28Hour-2C+Minute-2C+Second-2C+Subsecond-29">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><code>%H</code> - Hour of the day, in range (0..23), zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%H&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;01&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%H&#39;</span>) <span class="ruby-comment"># =&gt; &quot;13&quot;</span>
</pre>
</li><li>
<p><code>%k</code> - Hour of the day, in range (0..23), blank-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%k&#39;</span>)  <span class="ruby-comment"># =&gt; &quot; 1&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%k&#39;</span>) <span class="ruby-comment"># =&gt; &quot;13&quot;</span>
</pre>
</li><li>
<p><code>%I</code> - Hour of the day, in range (1..12), zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%I&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;01&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%I&#39;</span>) <span class="ruby-comment"># =&gt; &quot;01&quot;</span>
</pre>
</li><li>
<p><code>%l</code> - Hour of the day, in range (1..12), blank-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%l&#39;</span>)  <span class="ruby-comment"># =&gt; &quot; 1&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%l&#39;</span>) <span class="ruby-comment"># =&gt; &quot; 1&quot;</span>
</pre>
</li><li>
<p><code>%P</code> - Meridian indicator, lowercase:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%P&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;am&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%P&#39;</span>) <span class="ruby-comment"># =&gt; &quot;pm&quot;</span>
</pre>
</li><li>
<p><code>%p</code> - Meridian indicator, uppercase:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%p&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;AM&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%p&#39;</span>) <span class="ruby-comment"># =&gt; &quot;PM&quot;</span>
</pre>
</li><li>
<p><code>%M</code> - Minute of the hour, in range (0..59), zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%M&#39;</span>) <span class="ruby-comment"># =&gt; &quot;00&quot;</span>
</pre>
</li><li>
<p><code>%S</code> - Second of the minute in range (0..59), zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%S&#39;</span>) <span class="ruby-comment"># =&gt; &quot;00&quot;</span>
</pre>
</li><li>
<p><code>%L</code> - Millisecond of the second, in range (0..999), zero-padded:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%L&#39;</span>) <span class="ruby-comment"># =&gt; &quot;000&quot;</span>
</pre>
</li><li>
<p><code>%N</code> - Fractional seconds, default width is 9 digits (nanoseconds):</p>

<pre class="ruby"><span class="ruby-identifier">t</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>       <span class="ruby-comment"># =&gt; 2022-06-29 07:10:20.3230914 -0500</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%N&#39;</span>)   <span class="ruby-comment"># =&gt; &quot;323091400&quot;                  # Default.</span>
</pre>

<p>Use <a href="strftime_formatting_rdoc.html#label-Width+Specifiers">width specifiers</a> to adjust units:</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%3N&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;323&quot;                      # Milliseconds.</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%6N&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;323091&quot;                   # Microseconds.</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%9N&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;323091400&quot;                # Nanoseconds.</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%12N&#39;</span>) <span class="ruby-comment"># =&gt; &quot;323091400000&quot;             # Picoseconds.</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%15N&#39;</span>) <span class="ruby-comment"># =&gt; &quot;323091400000000&quot;          # Femptoseconds.</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%18N&#39;</span>) <span class="ruby-comment"># =&gt; &quot;323091400000000000&quot;       # Attoseconds.</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%21N&#39;</span>) <span class="ruby-comment"># =&gt; &quot;323091400000000000000&quot;    # Zeptoseconds.</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%24N&#39;</span>) <span class="ruby-comment"># =&gt; &quot;323091400000000000000000&quot; # Yoctoseconds.</span>
</pre>
</li><li>
<p><code>%s</code> - Number of seconds since the epoch:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%s&#39;</span>) <span class="ruby-comment"># =&gt; &quot;1656505136&quot;</span>
</pre>
</li></ul>

<h4 id="label-Timezone">Timezone<span><a href="#label-Timezone">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><code>%z</code> - Timezone as hour and minute offset from UTC:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%z&#39;</span>) <span class="ruby-comment"># =&gt; &quot;-0500&quot;</span>
</pre>
</li><li>
<p><code>%Z</code> - Timezone name (platform-dependent):</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Z&#39;</span>) <span class="ruby-comment"># =&gt; &quot;Central Daylight Time&quot;</span>
</pre>
</li></ul>

<h4 id="label-Weekday">Weekday<span><a href="#label-Weekday">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><code>%A</code> - Full weekday name:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%A&#39;</span>) <span class="ruby-comment"># =&gt; &quot;Wednesday&quot;</span>
</pre>
</li><li>
<p><code>%a</code> - Abbreviated weekday name:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%a&#39;</span>) <span class="ruby-comment"># =&gt; &quot;Wed&quot;</span>
</pre>
</li><li>
<p><code>%u</code> - Day of the week, in range (1..7), Monday is 1:</p>

<pre class="ruby"><span class="ruby-identifier">t</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">6</span>, <span class="ruby-value">26</span>) <span class="ruby-comment"># =&gt; 2022-06-26 00:00:00 -0500</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%a&#39;</span>)          <span class="ruby-comment"># =&gt; &quot;Sun&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%u&#39;</span>)          <span class="ruby-comment"># =&gt; &quot;7&quot;</span>
</pre>
</li><li>
<p><code>%w</code> - Day of the week, in range (0..6), Sunday is 0:</p>

<pre class="ruby"><span class="ruby-identifier">t</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">6</span>, <span class="ruby-value">26</span>) <span class="ruby-comment"># =&gt; 2022-06-26 00:00:00 -0500</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%a&#39;</span>)          <span class="ruby-comment"># =&gt; &quot;Sun&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%w&#39;</span>)          <span class="ruby-comment"># =&gt; &quot;0&quot;</span>
</pre>
</li></ul>

<h4 id="label-Week+Number">Week Number<span><a href="#label-Week+Number">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><code>%U</code> - Week number of the year, in range (0..53), zero-padded, where each week begins on a Sunday:</p>

<pre class="ruby"><span class="ruby-identifier">t</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">6</span>, <span class="ruby-value">26</span>) <span class="ruby-comment"># =&gt; 2022-06-26 00:00:00 -0500</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%a&#39;</span>)          <span class="ruby-comment"># =&gt; &quot;Sun&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%U&#39;</span>)          <span class="ruby-comment"># =&gt; &quot;26&quot;</span>
</pre>
</li><li>
<p><code>%W</code> - Week number of the year, in range (0..53), zero-padded, where each week begins on a Monday:</p>

<pre class="ruby"><span class="ruby-identifier">t</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">6</span>, <span class="ruby-value">26</span>) <span class="ruby-comment"># =&gt; 2022-06-26 00:00:00 -0500</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%a&#39;</span>)          <span class="ruby-comment"># =&gt; &quot;Sun&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%W&#39;</span>)          <span class="ruby-comment"># =&gt; &quot;25&quot;</span>
</pre>
</li></ul>

<h4 id="label-Week+Dates">Week Dates<span><a href="#label-Week+Dates">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>See <a href="https://en.wikipedia.org/wiki/ISO_8601#Week_dates">ISO 8601 week dates</a>.</p>

<pre class="ruby"><span class="ruby-identifier">t0</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2023</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 2023-01-01 00:00:00 -0600</span>
<span class="ruby-identifier">t1</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2024</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>) <span class="ruby-comment"># =&gt; 2024-01-01 00:00:00 -0600</span>
</pre>
<ul><li>
<p><code>%G</code> - Week-based year:</p>

<pre class="ruby"><span class="ruby-identifier">t0</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%G&#39;</span>) <span class="ruby-comment"># =&gt; &quot;2022&quot;</span>
<span class="ruby-identifier">t1</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%G&#39;</span>) <span class="ruby-comment"># =&gt; &quot;2024&quot;</span>
</pre>
</li><li>
<p><code>%g</code> - Week-based year without century, in range (0..99), zero-padded:</p>

<pre class="ruby"><span class="ruby-identifier">t0</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%g&#39;</span>) <span class="ruby-comment"># =&gt; &quot;22&quot;</span>
<span class="ruby-identifier">t1</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%g&#39;</span>) <span class="ruby-comment"># =&gt; &quot;24&quot;</span>
</pre>
</li><li>
<p><code>%V</code> - Week number of the week-based year, in range (1..53), zero-padded:</p>

<pre class="ruby"><span class="ruby-identifier">t0</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%V&#39;</span>) <span class="ruby-comment"># =&gt; &quot;52&quot;</span>
<span class="ruby-identifier">t1</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%V&#39;</span>) <span class="ruby-comment"># =&gt; &quot;01&quot;</span>
</pre>
</li></ul>

<h4 id="label-Literals">Literals<span><a href="#label-Literals">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><code>%n</code> - Newline character “n”:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%n&#39;</span>) <span class="ruby-comment"># =&gt; &quot;\n&quot;</span>
</pre>
</li><li>
<p><code>%t</code> - Tab character “t”:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%t&#39;</span>) <span class="ruby-comment"># =&gt; &quot;\t&quot;</span>
</pre>
</li><li>
<p><code>%%</code> - Percent character ‘%’:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%%&#39;</span>) <span class="ruby-comment"># =&gt; &quot;%&quot;</span>
</pre>
</li></ul>

<h4 id="label-Shorthand+Conversion+Specifiers">Shorthand Conversion Specifiers<span><a href="#label-Shorthand+Conversion+Specifiers">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>Each shorthand specifier here is shown with its corresponding longhand specifier.</p>
<ul><li>
<p><code>%c</code> - Date and time:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%c&#39;</span>)             <span class="ruby-comment"># =&gt; &quot;Wed Jun 29 08:01:41 2022&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%a %b %e %T %Y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;Wed Jun 29 08:02:07 2022&quot;</span>
</pre>
</li><li>
<p><code>%D</code> - Date:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%D&#39;</span>)       <span class="ruby-comment"># =&gt; &quot;06/29/22&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%m/%d/%y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;06/29/22&quot;</span>
</pre>
</li><li>
<p><code>%F</code> - ISO 8601 date:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%F&#39;</span>)       <span class="ruby-comment"># =&gt; &quot;2022-06-29&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y-%m-%d&#39;</span>) <span class="ruby-comment"># =&gt; &quot;2022-06-29&quot;</span>
</pre>
</li><li>
<p><code>%v</code> - VMS date:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%v&#39;</span>)         <span class="ruby-comment"># =&gt; &quot;29-JUN-2022&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%e-%^b-%4Y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;29-JUN-2022&quot;</span>
</pre>
</li><li>
<p><code>%x</code> - Same as <code>%D</code>.</p>
</li><li>
<p><code>%X</code> - Same as <code>%T</code>.</p>
</li><li>
<p><code>%r</code> - 12-hour time:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%r&#39;</span>)           <span class="ruby-comment"># =&gt; &quot;01:00:00 AM&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%I:%M:%S %p&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;01:00:00 AM&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%r&#39;</span>)          <span class="ruby-comment"># =&gt; &quot;01:00:00 PM&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%I:%M:%S %p&#39;</span>) <span class="ruby-comment"># =&gt; &quot;01:00:00 PM&quot;</span>
</pre>
</li><li>
<p><code>%R</code> - 24-hour time:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%R&#39;</span>)     <span class="ruby-comment"># =&gt; &quot;01:00&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%H:%M&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;01:00&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%R&#39;</span>)    <span class="ruby-comment"># =&gt; &quot;13:00&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%H:%M&#39;</span>) <span class="ruby-comment"># =&gt; &quot;13:00&quot;</span>
</pre>
</li><li>
<p><code>%T</code> - 24-hour time:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%T&#39;</span>)        <span class="ruby-comment"># =&gt; &quot;01:00:00&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%H:%M:%S&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;01:00:00&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%T&#39;</span>)       <span class="ruby-comment"># =&gt; &quot;13:00:00&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>, <span class="ruby-value">1</span>, <span class="ruby-value">13</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%H:%M:%S&#39;</span>) <span class="ruby-comment"># =&gt; &quot;13:00:00&quot;</span>
</pre>
</li><li>
<p><code>%+</code> (not supported in <a href="Time.html#method-i-strftime"><code>Time#strftime</code></a>) - Date and time:</p>

<pre class="ruby"><span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%+&#39;</span>)
<span class="ruby-comment"># =&gt; &quot;Wed Jun 29 08:31:53 -05:00 2022&quot;</span>
<span class="ruby-constant">DateTime</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%a %b %e %H:%M:%S %Z %Y&#39;</span>)
<span class="ruby-comment"># =&gt; &quot;Wed Jun 29 08:32:18 -05:00 2022&quot;</span>
</pre>
</li></ul>

<h3 id="label-Flags">Flags<span><a href="#label-Flags">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>Flags may affect certain formatting specifications.</p>

<p>Multiple flags may be given with a single conversion specified; order does not matter.</p>

<h4 id="label-Padding+Flags">Padding Flags<span><a href="#label-Padding+Flags">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><code>0</code> - Pad with zeroes:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">10</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%0Y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;0010&quot;</span>
</pre>
</li><li>
<p><code>_</code> - Pad with blanks:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">10</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%_Y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;  10&quot;</span>
</pre>
</li><li>
<p><code>-</code> - Don’t pad:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">10</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%-Y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;10&quot;</span>
</pre>
</li></ul>

<h4 id="label-Casing+Flags">Casing Flags<span><a href="#label-Casing+Flags">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><code>^</code> - Upcase result:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%B&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;January&quot; # No casing flag.</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2022</span>, <span class="ruby-value">1</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%^B&#39;</span>) <span class="ruby-comment"># =&gt; &quot;JANUARY&quot;</span>
</pre>
</li><li>
<p><code>#</code> - Swapcase result:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%p&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;AM&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%^p&#39;</span>) <span class="ruby-comment"># =&gt; &quot;AM&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%#p&#39;</span>) <span class="ruby-comment"># =&gt; &quot;am&quot;</span>
</pre>
</li></ul>

<h4 id="label-Timezone+Flags">Timezone Flags<span><a href="#label-Timezone+Flags">&para;</a> <a href="#top">&uarr;</a></span></h4>
<ul><li>
<p><code>:</code> - Put timezone as colon-separated hours and minutes:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%:z&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;-05:00&quot;</span>
</pre>
</li><li>
<p><code>::</code> - Put timezone as colon-separated hours, minutes, and seconds:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%::z&#39;</span>) <span class="ruby-comment"># =&gt; &quot;-05:00:00&quot;</span>
</pre>
</li></ul>

<h3 id="label-Width+Specifiers">Width Specifiers<span><a href="#label-Width+Specifiers">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The integer width specifier gives a minimum width for the returned string:</p>

<pre class="ruby"><span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y&#39;</span>)       <span class="ruby-comment"># =&gt; &quot;2002&quot;     # No width specifier.</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%10Y&#39;</span>)     <span class="ruby-comment"># =&gt; &quot;0000002002&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>, <span class="ruby-value">12</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%B&#39;</span>)   <span class="ruby-comment"># =&gt; &quot;December&quot; # No width specifier.</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>, <span class="ruby-value">12</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%10B&#39;</span>) <span class="ruby-comment"># =&gt; &quot;  December&quot;</span>
<span class="ruby-constant">Time</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2002</span>, <span class="ruby-value">12</span>).<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%3B&#39;</span>)  <span class="ruby-comment"># =&gt; &quot;December&quot; # Ignored if too small.</span>
</pre>

<h2 id="label-Specialized+Format+Strings">Specialized Format Strings<span><a href="#label-Specialized+Format+Strings">&para;</a> <a href="#top">&uarr;</a></span></h2>

<p>Here are a few specialized format strings, each based on an external standard.</p>

<h3 id="label-HTTP+Format">HTTP Format<span><a href="#label-HTTP+Format">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The HTTP date format is based on <a href="https://datatracker.ietf.org/doc/html/rfc2616">RFC 2616</a>, and treats dates in the format <code>&#39;%a, %d %b %Y %T GMT&#39;</code>:</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2001</span>, <span class="ruby-value">2</span>, <span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; #&lt;Date: 2001-02-03&gt;</span>
<span class="ruby-comment"># Return HTTP-formatted string.</span>
<span class="ruby-identifier">httpdate</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">httpdate</span>    <span class="ruby-comment"># =&gt; &quot;Sat, 03 Feb 2001 00:00:00 GMT&quot;</span>
<span class="ruby-comment"># Return new date parsed from HTTP-formatted string.</span>
<span class="ruby-constant">Date</span>.<span class="ruby-identifier">httpdate</span>(<span class="ruby-identifier">httpdate</span>)  <span class="ruby-comment"># =&gt; #&lt;Date: 2001-02-03&gt;</span>
<span class="ruby-comment"># Return hash parsed from HTTP-formatted string.</span>
<span class="ruby-constant">Date</span>.<span class="ruby-identifier">_httpdate</span>(<span class="ruby-identifier">httpdate</span>)
<span class="ruby-comment"># =&gt; {:wday=&gt;6, :mday=&gt;3, :mon=&gt;2, :year=&gt;2001, :hour=&gt;0, :min=&gt;0, :sec=&gt;0, :zone=&gt;&quot;GMT&quot;, :offset=&gt;0}</span>
</pre>

<h3 id="label-RFC+3339+Format">RFC 3339 Format<span><a href="#label-RFC+3339+Format">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The RFC 3339 date format is based on <a href="https://datatracker.ietf.org/doc/html/rfc3339">RFC 3339</a>:</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2001</span>, <span class="ruby-value">2</span>, <span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; #&lt;Date: 2001-02-03&gt;</span>
<span class="ruby-comment"># Return 3339-formatted string.</span>
<span class="ruby-identifier">rfc3339</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">rfc3339</span>      <span class="ruby-comment"># =&gt; &quot;2001-02-03T00:00:00+00:00&quot;</span>
<span class="ruby-comment"># Return new date parsed from 3339-formatted string.</span>
<span class="ruby-constant">Date</span>.<span class="ruby-identifier">rfc3339</span>(<span class="ruby-identifier">rfc3339</span>)    <span class="ruby-comment"># =&gt; #&lt;Date: 2001-02-03&gt;</span>
<span class="ruby-comment"># Return hash parsed from 3339-formatted string.</span>
<span class="ruby-constant">Date</span>.<span class="ruby-identifier">_rfc3339</span>(<span class="ruby-identifier">rfc3339</span>)
<span class="ruby-comment"># =&gt; {:year=&gt;2001, :mon=&gt;2, :mday=&gt;3, :hour=&gt;0, :min=&gt;0, :sec=&gt;0, :zone=&gt;&quot;+00:00&quot;, :offset=&gt;0}</span>
</pre>

<h3 id="label-RFC+2822+Format">RFC 2822 Format<span><a href="#label-RFC+2822+Format">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The RFC 2822 date format is based on <a href="https://datatracker.ietf.org/doc/html/rfc2822">RFC 2822</a>, and treats dates in the format <code>&#39;%a, %-d %b %Y %T %z&#39;</code>]:</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2001</span>, <span class="ruby-value">2</span>, <span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; #&lt;Date: 2001-02-03&gt;</span>
<span class="ruby-comment"># Return 2822-formatted string.</span>
<span class="ruby-identifier">rfc2822</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">rfc2822</span>      <span class="ruby-comment"># =&gt; &quot;Sat, 3 Feb 2001 00:00:00 +0000&quot;</span>
<span class="ruby-comment"># Return new date parsed from 2822-formatted string.</span>
<span class="ruby-constant">Date</span>.<span class="ruby-identifier">rfc2822</span>(<span class="ruby-identifier">rfc2822</span>)    <span class="ruby-comment"># =&gt; #&lt;Date: 2001-02-03&gt;</span>
<span class="ruby-comment"># Return hash parsed from 2822-formatted string.</span>
<span class="ruby-constant">Date</span>.<span class="ruby-identifier">_rfc2822</span>(<span class="ruby-identifier">rfc2822</span>)
<span class="ruby-comment"># =&gt; {:wday=&gt;6, :mday=&gt;3, :mon=&gt;2, :year=&gt;2001, :hour=&gt;0, :min=&gt;0, :sec=&gt;0, :zone=&gt;&quot;+0000&quot;, :offset=&gt;0}</span>
</pre>

<h3 id="label-JIS+X+0301+Format">JIS X 0301 Format<span><a href="#label-JIS+X+0301+Format">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>The JIS X 0301 format includes the <a href="https://en.wikipedia.org/wiki/Japanese_era_name">Japanese era name</a>, and treats dates in the format <code>&#39;%Y-%m-%d&#39;</code> with the first letter of the romanized era name prefixed:</p>

<pre class="ruby"><span class="ruby-identifier">d</span> = <span class="ruby-constant">Date</span>.<span class="ruby-identifier">new</span>(<span class="ruby-value">2001</span>, <span class="ruby-value">2</span>, <span class="ruby-value">3</span>) <span class="ruby-comment"># =&gt; #&lt;Date: 2001-02-03&gt;</span>
<span class="ruby-comment"># Return 0301-formatted string.</span>
<span class="ruby-identifier">jisx0301</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">jisx0301</span>    <span class="ruby-comment"># =&gt; &quot;H13.02.03&quot;</span>
<span class="ruby-comment"># Return new date parsed from 0301-formatted string.</span>
<span class="ruby-constant">Date</span>.<span class="ruby-identifier">jisx0301</span>(<span class="ruby-identifier">jisx0301</span>)  <span class="ruby-comment"># =&gt; #&lt;Date: 2001-02-03&gt;</span>
<span class="ruby-comment"># Return hash parsed from 0301-formatted string.</span>
<span class="ruby-constant">Date</span>.<span class="ruby-identifier">_jisx0301</span>(<span class="ruby-identifier">jisx0301</span>) <span class="ruby-comment"># =&gt; {:year=&gt;2001, :mon=&gt;2, :mday=&gt;3}</span>
</pre>

<h3 id="label-ISO+8601+Format+Specifications">ISO 8601 Format Specifications<span><a href="#label-ISO+8601+Format+Specifications">&para;</a> <a href="#top">&uarr;</a></span></h3>

<p>This section shows format specifications that are compatible with <a href="https://en.wikipedia.org/wiki/ISO_8601">ISO 8601</a>. Details for various formats may be seen at the links.</p>

<p>Examples in this section assume:</p>

<pre class="ruby"><span class="ruby-identifier">t</span> = <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span> <span class="ruby-comment"># =&gt; 2022-06-29 16:49:25.465246 -0500</span>
</pre>

<h4 id="label-Dates">Dates<span><a href="#label-Dates">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>See <a href="https://en.wikipedia.org/wiki/ISO_8601#Dates">ISO 8601 dates</a>.</p>
<ul><li>
<p><a href="https://en.wikipedia.org/wiki/ISO_8601#Years">Years</a>:</p>
<ul><li>
<p>Basic year (<code>YYYY</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;2022&quot;</span>
</pre>
</li><li>
<p>Expanded year (<code>±YYYYY</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;+%5Y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;+02022&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;-%5Y&#39;</span>) <span class="ruby-comment"># =&gt; &quot;-02022&quot;</span>
</pre>
</li></ul>
</li><li>
<p><a href="https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates">Calendar dates</a>:</p>
<ul><li>
<p>Basic date (<code>YYYYMMDD</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y%m%d&#39;</span>) <span class="ruby-comment"># =&gt; &quot;20220629&quot;</span>
</pre>
</li><li>
<p>Extended date (<code>YYYY-MM-DD</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y-%m-%d&#39;</span>) <span class="ruby-comment"># =&gt; &quot;2022-06-29&quot;</span>
</pre>
</li><li>
<p>Reduced extended date (<code>YYYY-MM</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y-%m&#39;</span>) <span class="ruby-comment"># =&gt; &quot;2022-06&quot;</span>
</pre>
</li></ul>
</li><li>
<p><a href="https://en.wikipedia.org/wiki/ISO_8601#Week_dates">Week dates</a>:</p>
<ul><li>
<p>Basic date (<code>YYYYWww</code> or <code>YYYYWwwD</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y%Ww&#39;</span>)   <span class="ruby-comment"># =&gt; &quot;202226w&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y%Ww%u&#39;</span>) <span class="ruby-comment"># =&gt; &quot;202226w3&quot;</span>
</pre>
</li><li>
<p>Extended date (<code>YYYY-Www</code> or &lt;tt&gt;YYYY-Www-D&lt;tt&gt;):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y-%Ww&#39;</span>)    <span class="ruby-comment"># =&gt; &quot;2022-26w&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y-%Ww-%u&#39;</span>) <span class="ruby-comment"># =&gt; &quot;2022-26w-3&quot;</span>
</pre>
</li></ul>
</li><li>
<p><a href="https://en.wikipedia.org/wiki/ISO_8601#Ordinal_dates">Ordinal dates</a>:</p>
<ul><li>
<p>Basic date (<code>YYYYDDD</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y%j&#39;</span>) <span class="ruby-comment"># =&gt; &quot;2022180&quot;</span>
</pre>
</li><li>
<p>Extended date (<code>YYYY-DDD</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;%Y-%j&#39;</span>) <span class="ruby-comment"># =&gt; &quot;2022-180&quot;</span>
</pre>
</li></ul>
</li></ul>

<h4 id="label-Times">Times<span><a href="#label-Times">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>See <a href="https://en.wikipedia.org/wiki/ISO_8601#Times">ISO 8601 times</a>.</p>
<ul><li>
<p>Times:</p>
<ul><li>
<p>Basic time (<code>Thhmmss.sss</code>, <code>Thhmmss</code>, <code>Thhmm</code>, or <code>Thh</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H%M%S.%L&#39;</span>) <span class="ruby-comment"># =&gt; &quot;T164925.465&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H%M%S&#39;</span>)    <span class="ruby-comment"># =&gt; &quot;T164925&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H%M&#39;</span>)      <span class="ruby-comment"># =&gt; &quot;T1649&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H&#39;</span>)        <span class="ruby-comment"># =&gt; &quot;T16&quot;</span>
</pre>
</li><li>
<p>Extended time (<code>Thh:mm:ss.sss</code>, <code>Thh:mm:ss</code>, or <code>Thh:mm</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H:%M:%S.%L&#39;</span>) <span class="ruby-comment"># =&gt; &quot;T16:49:25.465&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H:%M:%S&#39;</span>)    <span class="ruby-comment"># =&gt; &quot;T16:49:25&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H:%M&#39;</span>)       <span class="ruby-comment"># =&gt; &quot;T16:49&quot;</span>
</pre>
</li></ul>
</li><li>
<p><a href="https://en.wikipedia.org/wiki/ISO_8601#Time_zone_designators">Time zone designators</a>:</p>
<ul><li>
<p>Timezone (<code>time</code> represents a valid time, <code>hh</code> represents a valid 2-digit hour, and <code>mm</code> represents a valid 2-digit minute):</p>
<ul><li>
<p>Basic timezone (<code>time±hhmm</code>, <code>time±hh</code>, or <code>timeZ</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H%M%S%z&#39;</span>)              <span class="ruby-comment"># =&gt; &quot;T164925-0500&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H%M%S%z&#39;</span>).<span class="ruby-identifier">slice</span>(<span class="ruby-value">0</span><span class="ruby-operator">..</span><span class="ruby-value">-3</span>) <span class="ruby-comment"># =&gt; &quot;T164925-05&quot;</span>
<span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H%M%SZ&#39;</span>)               <span class="ruby-comment"># =&gt; &quot;T164925Z&quot;</span>
</pre>
</li><li>
<p>Extended timezone (<code>time±hh:mm</code>):</p>

<pre class="ruby"><span class="ruby-identifier">t</span>.<span class="ruby-identifier">strftime</span>(<span class="ruby-string">&#39;T%H:%M:%S%z&#39;</span>) <span class="ruby-comment"># =&gt; &quot;T16:49:25-0500&quot;</span>
</pre>
</li></ul>
</li><li>
<p>See also:</p>
<ul><li>
<p><a href="https://en.wikipedia.org/wiki/ISO_8601#Local_time_(unqualified)">Local time (unqualified)</a>.</p>
</li><li>
<p><a href="https://en.wikipedia.org/wiki/ISO_8601#Coordinated_Universal_Time_(UTC)">Coordinated Universal Time (UTC)</a>.</p>
</li><li>
<p><a href="https://en.wikipedia.org/wiki/ISO_8601#Time_offsets_from_UTC">Time offsets from UTC</a>.</p>
</li></ul>
</li></ul>
</li></ul>

<h4 id="label-Combined+Date+and+Time">Combined Date and Time<span><a href="#label-Combined+Date+and+Time">&para;</a> <a href="#top">&uarr;</a></span></h4>

<p>See <a href="https://en.wikipedia.org/wiki/ISO_8601#Combined_date_and_time_representations">ISO 8601 Combined date and time representations</a>.</p>

<p>An ISO 8601 combined date and time representation may be any ISO 8601 date and any ISO 8601 time, separated by the letter <code>T</code>.</p>

<p>For the relevant <code>strftime</code> formats, see <a href="strftime_formatting_rdoc.html#label-Dates">Dates</a> and <a href="strftime_formatting_rdoc.html#label-Times">Times</a> above.</p>

</main>

</div>  <!--  class='wrapper hdiv' -->


<footer id="validator-badges" role="contentinfo">
<p><a href="https://validator.w3.org/check/referer">Validate</a></p>
<p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.4.0.</p>
<p>Based on <a href="https://github.com/ged/darkfish/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>

  
    <p><p><a href="https://ruby-doc.org">Ruby-doc.org</a> is provided by <a href="https://jamesbritt.com">James Britt</a> and <a href="https://neurogami.com">Neurogami</a>.</p><p><a href="https://jamesbritt.bandcamp.com/">Maximum R+D</a>.  </p>
</p>
  
  </footer>

<script type="text/javascript">


  let ads  = $("#carbonads-container").children().detach();


  function swapMode() {
    var cookieName = 'darkmode';
    var cssDarkmode = Cookies.get(cookieName);
    console.log("***** swapMode! " + cssDarkmode + " *****");


    if (cssDarkmode == "true") {
      console.log("We have dark mode, set the css to light ...");
      $('#rdoccss').attr("href", defaultModeCssHref);
      $('#cssSelect').text("Dark mode");
      cssDarkmode = "false";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    } else {
      console.log("We not have dark mode, set the css to dark ...");
      $('#rdoccss').attr("href", darkModeCsseHref);
      $('#cssSelect').text("Light mode");
      cssDarkmode = "true";
      console.log("swapMode! Now set cookie to " + cssDarkmode);
      Cookies.set(cookieName, cssDarkmode);

    }

    console.log("  --------------- ");
  }


const vueCssApp = new Vue({
el: '#menubar',
data: {
isDark: false
},
methods: {
toggleClass: function(event){
this.isDark = !this.isDark;
}
}
})

const vueApp = new Vue({
el: '#vapp',
data: { 
isOpen: true
},

mounted() {
this.handleResize();
this.manage_mob_classes();
window.addEventListener('resize', this.handleResize)
//this.isOpen !=  (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},
destroyed() {
window.removeEventListener('resize', this.handleResize)
},
created() {
//manage_mob_classes();
},

methods : {
isMobile() {
  return (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent));
},

  handleResize() {
    if (!this.isMobile()) {
      this.isOpen = window.innerWidth > 800;
    }
  },

  manage_mob_classes() {
    if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
      $("nav").addClass("mob_nav");
      $("main").addClass("mob_main");
      $("#extraz").addClass("mob_extraz");
      $("#carbonads-container").addClass("mob_carbonads-container");
      this.isOpen  = false;
    } else {
      $("nav").removeClass("mob_nav") 
        $("main").removeClass("mob_main");
      $("#extraz").removeClass("mob_extraz");
      $("#carbonads-container").removeClass("mob_carbonads-container");
      this.isOpen  = true;
    }
  },

  toggleNav() {
    this.isOpen =! this.isOpen ;
    // alert("Toggle nav!");
    console.log("toggleNav() click: " + this.isOpen );
  }
}
})

$("#carbonads-container").append(ads);


$(function() {

    var darkmode = Cookies.get("darkmode");
    console.log("Document ready: " + darkmode);

    if ( darkmode  == "true" ) {
      $('#cssSelect').text("Light mode");
    } else {
      $('#cssSelect').text("Dark mode");
     }

    $('body').css('display','block');
    });

</script>

    
  </body> 
</html>

